﻿using System;
using System.Collections.Generic;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using SmlEngine.UI.Screens;

namespace SmlEngine.UI.Controls
{
    public class Label : Control
    {
        public string Text { get; set; }
        public SpriteFont Font { get; set; }
        public Color ForeColor { get; set; }

        public override Rectangle Bounds
        {
            get
            {
                return new Rectangle(base.Bounds.X, base.Bounds.Y, 
                    (int)Font.MeasureString(Text).X, (int)Font.MeasureString(Text).Y);
            }
            set
            {
                base.Bounds = new Rectangle(value.X, value.Y, Bounds.X, Bounds.Y);
            }
        }

        public Label(Screen screen, string text)
            : base(screen)
        {
            Text = text;
            Font = screen.ScreenManager.DefaultFont;
            ForeColor = Color.White;
        }

        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            Draw(gameTime, spriteBatch, Point.Zero);
        }

        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch, Point offset)
        {
            spriteBatch.DrawString(Font, Text, new Vector2(Bounds.X + offset.X, Bounds.Y + offset.Y), ForeColor);
            base.Draw(gameTime, spriteBatch, offset);
        }
    }
}
